package cc.dd.marketing.api.constant;

/**
 *
 * @author dongsufeng
 * @date 2022/9/9 10:46 AM
 */
public class ResultUtil {


    public static ResultDTO defaultResult() {
        return new ResultDTO();
    }

    public static ResultDTO success(Object model) {
        ResultDTO result = defaultResult();
        result.setData(model);
        result.setSuccess(Boolean.TRUE);
        return result;
    }

    public static ResultDTO fail(String errorCode, String errorMessage) {
        ResultDTO result = defaultResult();
        result.setSuccess(Boolean.FALSE);
        result.setCode(errorCode);
        result.setMessage(errorMessage);
        return result;
    }

    public static boolean isResultSuccess(ResultDTO result) {
        return null != result && result.getSuccess();
    }

}
